package Template5::DTD::Element;

use strict;
use warnings;

#-------------------------------------------------------------------------------
#public
sub new($$$)
{
	my $class     = shift;
	my $hDTD      = shift;	
	my $localname = shift;
	my $allowed   = shift;

	my $this = {'dtd'       => $hDTD,
							'localname' => $localname,
							'allowed'   => $allowed};
	
	return bless($this, $class);
};

#public
sub child_allowed($)
{
	my $this    = shift;
	my $hDTDElm = shift;

	my $retVal = 0;
	my $localname = $this->{'dtd'}->element_localname($hDTDElm);
		
	if(defined($localname))
	{
		foreach my $allowednameref (@{$this->{'allowed'}})
		{
			my $allowedname = $allowednameref;
		
			if(($allowedname =~ /^(.*)\:\:$/))
			{
				my $prefix = $1;

				if(($prefix eq '' && $localname !~ /\:\:/) || ($localname =~ /^$allowedname/))
				{
					$allowedname = $localname;				 
			 	};
			};
			
			if($localname eq $allowedname)
			{
				$retVal = 1;
				last;
			};		
		};
	};

	return $retVal;
};

#public
sub is_container()
{
	my $this = shift;	
	return scalar(@{$this->{'allowed'}}) != 0;
};

1;

